import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'


// https://vitejs.dev/config/
export default defineConfig(({ command, mode, ssrBuild }) => {
  // 获取当前环境的配置
  const config = loadEnv(mode, './');
  return {
    plugins: [vue()],
    base: config.VITE_PUBLIC_PATH,
    resolve: {
      alias: {
        '@': path.join(__dirname, 'src')
      }
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
          additionalData:  `@import "${path.resolve(__dirname, 'src/assets/css/global-style.less')}";`
        }
      }
    },
    server: {
      host: '0.0.0.0',
      port: '8100',
      // proxy: {
      //   '/cdapi/': {
      //       target: "http://192.168.5.190:8090",
      //       changeOrigin: true,
      //       secure: false,
      //   }
      // }
    }
  }
    
})
